package com.xinongbest.course.controller;

import com.xinongbest.course.client.CourseListClient;
import com.xinongbest.course.entity.Course;
import com.xinongbest.course.entity.CourseListAndPrice;
import com.xinongbest.course.service.CoursePriceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class CoursePriceController {
    @Autowired
    CoursePriceService coursePriceService;

    @Autowired
    CourseListClient courseListClient;

    @GetMapping("/getPrice")
    public Integer getCoursePrice(Integer courseId) {
        return coursePriceService.getCoursePriceById(courseId);
    }

    @GetMapping("/course-list-price")
    public List<Course> courseList() {
        return courseListClient.courseList();
    }

    @GetMapping("/course")
    public List<CourseListAndPrice> courseListAndPrice() {
        return coursePriceService.getCourseListAndPrice();
    }
}
